#region Microsoft Public License
/*
 * (c) Copyright Chenjun Wu. http://utablesdk.codeplex.com
 * 
 * This source is subject to the Microsoft Public License (Ms-PL).
 * Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
 * All other rights reserved.
 */
#endregion

﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using UTable.Input;
using UTable.Input.MultiTouch;
using UTable.Objects;
using UTable.Objects.Controls;

namespace UTable.Tests
{
    /// <summary>
    /// Interaction logic for UGridViewTest.xaml
    /// </summary>
    public partial class UGridViewTest : UObject
    {
		private double itemWidth = 100;
		private double itemHeight = 150;
		private Thickness layoutMargin = new Thickness(20, 10, 20, 30);
		private Thickness cellMargin = new Thickness(10);

        public UGridViewTest()
        {
            InitializeComponent();
        }

		private void DirectionBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			if (this.IsLoaded)
			{
				if (DirectionBox.SelectedIndex == 0)
				{
					GridViewer.LayoutDirection = UGridViewLayoutDirection.LeftRightDown;
				}
				else if (DirectionBox.SelectedIndex == 1)
				{
					GridViewer.LayoutDirection = UGridViewLayoutDirection.TopDownRight;
				}
			}
		}

		private void USlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
		{
			if (this.IsLoaded)
			{
				GridViewer.ItemWidth = itemWidth * ItemScaleSlider.Value;
				GridViewer.ItemHeight = itemHeight * ItemScaleSlider.Value;
			}
		}

		private void LayoutMarginScaleSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
		{
			if (this.IsLoaded)
			{
				GridViewer.LayoutMargin = new Thickness(layoutMargin.Left * LayoutMarginScaleSlider.Value,
														layoutMargin.Top * LayoutMarginScaleSlider.Value,
														layoutMargin.Right * LayoutMarginScaleSlider.Value,
														layoutMargin.Bottom * LayoutMarginScaleSlider.Value);
			}
		}

		private void CellMarginScaleSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
		{
			if (this.IsLoaded)
			{
				GridViewer.CellMargin = new Thickness(cellMargin.Left * CellMarginScaleSlider.Value,
														cellMargin.Top * CellMarginScaleSlider.Value,
														cellMargin.Right * CellMarginScaleSlider.Value,
														cellMargin.Bottom * CellMarginScaleSlider.Value);
			}
		}
    }
}
